package com.xiyu.service.controller.admin.files;
import com.xiyu.service.vo.files.landOwnership.LandOwnershipSingleGetOutput;
import com.xiyu.service.vo.files.landOwnership.LandOwnershipUpdateInput;
import com.xiyu.service.vo.files.landOwnership.LandOwnershipCreateInput;
import com.xiyu.service.vo.files.landOwnership.LandOwnershipPageQueryOutput;
import com.xiyu.service.vo.files.landOwnership.LandOwnershipPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.files.LandOwnershipService;

@Tag(name = "土地使用权证")
@RestController
@RequestMapping("/files/land-ownership")
@Validated
public class LandOwnershipController {

    @Resource
    private LandOwnershipService landOwnershipService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询土地使用权证")
    @PreAuthorize("@ss.hasPermission('files:landOwnership:query')")
    public CommonResult<PageResult<LandOwnershipPageQueryOutput>> pageQuery(@Valid LandOwnershipPageQueryInput inputVO) {
        return success(landOwnershipService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增土地使用权证")
    @PreAuthorize("@ss.hasPermission('files:landOwnership:create')")
    public CommonResult<Long> create(@Valid @RequestBody LandOwnershipCreateInput inputVO) {
        return success(landOwnershipService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新土地使用权证")
    @PreAuthorize("@ss.hasPermission('files:landOwnership:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody LandOwnershipUpdateInput inputVO) {
        return success(landOwnershipService.update(inputVO));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个土地使用权证")
    @Parameter(name = "id", description = "土地使用权证主键ID", example = "")
    public CommonResult<LandOwnershipSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(landOwnershipService.singleGet(id));
    }

}
